package ws.very.web.tpl

/**
 * Formatter for XML content.
 */
object XmlFormat extends Format[Xml] {

  /**
   * Creates an XML fragment.
   */
  def raw(text: String) = Xml(text)

  /**
   * Creates an escaped XML fragment.
   */
  def escape(text: String) = Xml(text) // Xml(org.apache.commons.lang3.StringEscapeUtils.escapeXml(text)) FIXME:

}
/**
 * Formatter for text content.
 */
object TxtFormat extends Format[Txt] {

  /**
   * Create a text fragment.
   */
  def raw(text: String) = Txt(text)

  /**
   * No need for a safe (escaped) text fragment.
   */
  def escape(text: String) = Txt(text)

}

trait Format[T <: Appendable[T]] {
  def raw(text: String): T
  def escape(text: String): T // FIXME:
}
/**
 * Formatter for HTML content.
 */
object HtmlFormat extends Format[Html] {

  /**
   * Creates a raw (unescaped) HTML fragment.
   */
  def raw(text: String): Html = Html(text)

  /**
   * Creates a safe (escaped) HTML fragment.
   */
  def escape(text: String): Html = Html(text) //Html(org.apache.commons.lang3.StringEscapeUtils.escapeHtml4(text)) FIXME:

}